home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CUJ9206.ARJ / 1006090B < prev    next >
Text File  |  1992-06-02  |  656b  |  37 lines

  1. /* LISTING 5 */
  2.  
  3. #define DM1init                 
  4.  
  5. #define DM1type                 double * 
  6.  
  7. DM1init;
  8.  
  9. DM1type DM1alloc(int r, int c) {
  10.     return (double *)
  11.         malloc((unsigned)r*c*(sizeof(double)));
  12. }
  13.  
  14. #define DM1item(x,i,j,c)        x[(i)*(c)+(j)]
  15.  
  16. void DM1free(DM1type x) {
  17.     free((void *)x);
  18. }
  19.  
  20. main()
  21. {
  22.     DM1type m;
  23.     int i,j;
  24.  
  25.     m = DM1alloc(7,13);
  26.     for(i=0; i<7; ++i)
  27.         for(j=0; j<13; ++j)
  28.             DM1item(m,i,j,13) = (double) (i*100)+j;
  29.  
  30.     for(i=0; i<7; ++i) {
  31.         for(j=0; j<13; ++j)
  32.             printf("%3g ",DM1item(m,i,j,13) );
  33.         printf("\n");
  34.     }
  35.     DM1free(m);
  36. }
  37.